package com.ling.pl.security.feign;

import com.ling.pl.security.model.DefaultOrgVO;
import com.ling.pl.security.model.DefaultRoleVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author bo.wang
 */
@RequestMapping("/defaultUser")
@FeignClient(name = "LING-CLOUD-BASE")
public interface DefaultUserService extends BaseDefaultUserService {

    @RequestMapping(value = "/loadUserOrgs", method = RequestMethod.GET)
    public Collection<DefaultOrgVO> loadUserOrgs(@RequestParam("username") String username);

    @RequestMapping(value = "/loadUserRoles", method = RequestMethod.GET)
    public Collection<DefaultRoleVO> loadUserRoles(@RequestParam("username") String username);

    /**
     * 这个方法用来判断在添加新用户时用户名是否已经存在
     *
     * @param username 用户输入的用户名
     */
    @RequestMapping(value = "/userIsExists", method = RequestMethod.GET)
    public String userIsExists(@RequestParam("username") String username);

    /**
     * 重置指定用户密码
     *
     * @param username
     * @return
     */
    @RequestMapping(value = "/resetPassword", method = RequestMethod.PUT)
    public String resetPassword(@RequestBody String username);

    @RequestMapping(value = "/insertUserPosition", method = RequestMethod.PUT)
    public void insertUserPosition(@RequestParam("username") String username, @RequestParam("ids") String ids);

    @RequestMapping(value = "/insertUserOrg", method = RequestMethod.PUT)
    public void insertUserOrg(@RequestParam("username") String username, @RequestParam("ids") String ids);

    @RequestMapping(value = "/registerCompanyAndUser", method = RequestMethod.POST)
    public void registerCompanyAndUser(@RequestBody Map<String, Object> companyAndUser) throws Exception;

    @RequestMapping(value = "/checkUserExist", method = RequestMethod.GET)
    public String checkUserExist(@RequestParam("username") String username);

    /**
     * 变更密码
     *
     * @param username
     * @param newPassword
     */
    @RequestMapping(value = "/changePassword", method = RequestMethod.PUT)
    public void changePassword(@RequestParam("username") String username, @RequestParam("newPassword") String newPassword);

    /**
     * 检查密码
     *
     * @param username
     * @param password
     * @return
     */
    @RequestMapping(value = "/checkPassword", method = RequestMethod.GET)
    public String checkPassword(@RequestParam(value = "username") String username, @RequestParam("password") String password);

    /**
     * 查询当前在线用户数量
     *
     * @return
     */
    @RequestMapping(value = "/getLoginuserCount", method = RequestMethod.GET)
    public int getLoginuserCount();

    /**
     * 查询当前在线用户列表
     *
     * @return
     */
    @RequestMapping(value = "/loadAllLoginUsers", method = RequestMethod.GET)
    public List<Map<String, Object>> loadAllLoginUsers();
}

